package com.seven.system.controller.api;

import com.seven.enity.Role;
import com.seven.system.service.RoleService;
import com.seven.vo.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author longlong
 * @date 2024/3/8 16:00
 * description
 */
@RestController
@RequestMapping("/systerm/role")
public class RoleController {
    @Resource
    private RoleService roleService;

    @GetMapping("getByUserId")
    public Result getByUserId(String userId){
        List<Role> roles=roleService.selectAll();
        List<String> roleIds= roleService.selectByUserId(userId);
        Map<String,Object> map=new HashMap<>();
        map.put("roles",roles);
        map.put("roleIds",roleIds);
        return new Result(2000,"查询成功",map);
    }

    @PostMapping("qrfp")
    public Result qrfp(String userId,String[] roleIds){
        roleService.qrfp(userId,roleIds);
        return new Result(2000,"分配成功",null);
    }
}
